texture imageTexture;
sampler baseMap = sampler_state
{
   Texture = (imageTexture);
};
float4 cmpColor;
float4 fillColor;
int range;
bool fillInside;

float4 Pixel_Shader_ps_main(float2 Texcoord : TEXCOORD0) : COLOR0
{
   cmpColor = cmpColor*255;
   int iHelp = (int)sqrt( pow(tex2D( baseMap, Texcoord ).x*255 - cmpColor.x, 2) +
                          pow(tex2D( baseMap, Texcoord ).y*255 - cmpColor.y, 2) +
                          pow(tex2D( baseMap, Texcoord ).z*255 - cmpColor.z, 2));
   if(fillInside==true)
   {
      if (iHelp >= range)
          return tex2D( baseMap, Texcoord );
      else
          return fillColor;
   }
   else
   {
      if (iHelp < range)
          return tex2D( baseMap, Texcoord );
      else
          return fillColor;
   }
   return tex2D( baseMap, Texcoord );
}

technique Textured
{
   pass Pass_0
   {
      PixelShader = compile ps_2_0 Pixel_Shader_ps_main();
   }
}

